#$file1 = $ARGV[0];
#chomp($file1);
#$file2 = $ARGV[1];
#chomp($file2);
#open(BUFF,"geno_segment1.bgl");

#open BUFF,"$file1" or die "no file $file1 not available\n";
open(BUFF,"/data1/bsi/BORA_processing/tcga_genotyping/results/LUAD_tumor.tped");
#$line = <BUFF>;
#$line = <BUFF>;
while($line = <BUFF>)
{
	chomp($line);
	@array = split(" ",$line);
	
	shift(@array);
	$snp  = shift(@array);
	shift(@array);
	shift(@array);
	$s = 1;
	$kk = 0;
	
	for($i=0;$i<@array;$i++)
	{
		$k1 = $array[$i];
		$i++;
		$k2 = $array[$i];
		$m =  $k1." ".$k2;
		#print $m."\n";
		 if($m eq "0 0")
		{
			$kk = $kk." ".$s;
			#print $kk."\n";
		}
		$s++;
	}
	$hash{$snp} =$kk;
}
=head
while(($k,$v) = each %hash)
{
	if($v ne "0")
	{
	print $k."\t$v\n";
	}
}
=cut
#open(BUFF,"beagle_out_1.geno_segment1.bgl.gz.gprobs");
#open(BUFF,$file2);
#open BUFF,$file2 or die "no $file2 not available\n";
open(BUFF,"final.dosage");
$line = <BUFF>;
while($line = <BUFF>)
{
        chomp($line);
	@array = split(" ",$line);
	$snp  = shift(@array);
	shift(@array);
	shift(@array);
	if(exists($hash{$snp}))
	{
		$s = 1;
		for($i=0;$i<@array;$i++)
		{
			$m = $array[$i];
			#$i++;
			#$m = $m." ".$array[$i];
			#$i++;
                        #$m = $m." ".$array[$i];
			#$val = $hash{$snp};
			#print "$m\t$s\t$val\n";
			if($m =~ m/\./ )
			{
				#print "$m\t$s\t$val\n";
				if(!($val =~ m/$s/))
				{	
					print $snp."\n";
					system("grep $snp $file1");
					system("grep $snp $file2");
				}
			}
			$s++;
		}
	}
}
